#include <iostream>
using namespace std;

//判断与顺序序列的中间值相等的值是否超过一半
int moreThanHalfNum_Solution(vector<int>& nums) {
    int n = nums.size();
    quick_sort(nums, 0, n - 1);
    int count = 0;
    int mid = nums[n / 2];
    for(int i = 0; i < n; i++){
        if(nums[i] == mid)  count++;
    }
    if(count > n / 2)   return mid;
    else return 0;

}
//快排
void quick_sort(vector<int>& nums, int l, int r){
    if(l >= r)  return ;

    int x = nums[(l + r) >> 1], i = l - 1, j = r + 1;
    while(i < j){
        do i++; while(nums[i] < x);
        do j--; while(nums[j] > x);
        if(i < j)   swap(nums[i], nums[j]); 
    }

    quick_sort(nums, l, j);
    quick_sort(nums, j + 1, r);

}

void test0(){
    vector<int> obj;
    for(int i=0;i<10;i++) 
    {
        obj.push_back(i);  
    }
    moreThanHalfNum_Solution(obj);
}

int main(){
    test0();
    return 0;
}